package com.oldbook.manage.service.impl;

import java.util.List;

import com.oldbook.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.oldbook.manage.mapper.TextbookCategoryMapper;
import com.oldbook.manage.domain.TextbookCategory;
import com.oldbook.manage.service.ITextbookCategoryService;

/**
 * 教材分类Service业务层处理
 * 
 * @author Exiaoke
 * @date 2025-02-17
 */
@Service
public class TextbookCategoryServiceImpl implements ITextbookCategoryService 
{
    @Autowired
    private TextbookCategoryMapper textbookCategoryMapper;

    /**
     * 查询教材分类
     * 
     * @param categoryId 教材分类主键
     * @return 教材分类
     */
    @Override
    public TextbookCategory selectTextbookCategoryByCategoryId(Long categoryId)
    {
        return textbookCategoryMapper.selectTextbookCategoryByCategoryId(categoryId);
    }

    /**
     * 查询教材分类列表
     * 
     * @param textbookCategory 教材分类
     * @return 教材分类
     */
    @Override
    public List<TextbookCategory> selectTextbookCategoryList(TextbookCategory textbookCategory)
    {
        return textbookCategoryMapper.selectTextbookCategoryList(textbookCategory);
    }

    /**
     * 新增教材分类
     * 
     * @param textbookCategory 教材分类
     * @return 结果
     */
    @Override
    public int insertTextbookCategory(TextbookCategory textbookCategory)
    {
        textbookCategory.setCreateTime(DateUtils.getNowDate());
        return textbookCategoryMapper.insertTextbookCategory(textbookCategory);
    }

    /**
     * 修改教材分类
     * 
     * @param textbookCategory 教材分类
     * @return 结果
     */
    @Override
    public int updateTextbookCategory(TextbookCategory textbookCategory)
    {
        textbookCategory.setUpdateTime(DateUtils.getNowDate());
        return textbookCategoryMapper.updateTextbookCategory(textbookCategory);
    }

    /**
     * 批量删除教材分类
     * 
     * @param categoryIds 需要删除的教材分类主键
     * @return 结果
     */
    @Override
    public int deleteTextbookCategoryByCategoryIds(Long[] categoryIds)
    {
        return textbookCategoryMapper.deleteTextbookCategoryByCategoryIds(categoryIds);
    }

    /**
     * 删除教材分类信息
     * 
     * @param categoryId 教材分类主键
     * @return 结果
     */
    @Override
    public int deleteTextbookCategoryByCategoryId(Long categoryId)
    {
        return textbookCategoryMapper.deleteTextbookCategoryByCategoryId(categoryId);
    }
}
